import numpy as np
from time import time

def benchmarks(n):
    t1 = time()
    a_list = list(range(1,n+1))  # Old style!
    tot = sum(a_list)
    t2 = time()
    print('Time taken by Python is',t2-t1)

    t3 = time()
    a = np.arange(1,n+1)  # Numpy!
    total = np.sum(a)
    t4 = time()
    print('Time taken by numpy is ',t4-t3)


benchmarks(10_000_000)   # numpy比Python语言处理速度更快，性能上更高效




